package models

import (
	"github.com/astaxie/beego/orm"
)

/*
** 参考文献信息
 */
type Reference struct {
	Id      int64
	RefId   string `orm:"size(10);index"`
	MolId   string `orm:"size(10);index"`
	MolName string `orm:"size(256);"`
	TrgId   string `orm:"size(10);index"`
	TrgName string `orm:"size(256);"`
	Doi     string `orm:"size(50);index"`
	RefName string `orm:"size(256)"`
	Pmid    string `orm:"size(20);index"` // Pubmed Id
}

func (m *Reference) TableName() string {
	return "reference"
}

func (m *Reference) Insert() error {
	if _, err := orm.NewOrm().Insert(m); err != nil {
		return err
	}
	return nil
}

func (m *Reference) Read(fields ...string) error {
	if err := orm.NewOrm().Read(m, fields...); err != nil {
		return err
	}
	return nil
}

func (m *Reference) Update(fields ...string) error {
	if _, err := orm.NewOrm().Update(m, fields...); err != nil {
		return err
	}
	return nil
}

func (m *Reference) Delete() error {
	if _, err := orm.NewOrm().Delete(m); err != nil {
		return err
	}
	return nil
}

func (m *Reference) Query() orm.QuerySeter {
	return orm.NewOrm().QueryTable(m)
}
